<?php if ( ! defined('ABSPATH')) exit('restricted access'); //stop direct script access

/** Stop execution if we don't have theme settings */
if( ! defined('THEME_NAME')) wp_die( __('Theme settings are missing in functions.php', THEME_NAME) );

/** Define Unique Theme Prefix to avoide conflict between multiple themes settings */
define('THEME_PREFIX', 'fw_'.THEME_NAME.'_');

/** Theme directory path */
define('THEME_PATH', get_template_directory());

/** Theme directory URL */
define('THEME_URL', get_template_directory_uri());

/** Home URL */
define('HOME_URL', home_url());

/** Define Base directory path */
define('BASEPATH', dirname(__FILE__));

/** Define WPnukes Apanel skin directory */
define('FW_ADMIN_SKIN', THEME_PATH.'/includes/views/');

/** Load core classes */
require_once('core/base_class.php');

/** Auto load helper functions */
$_webnukes->functions->load(array('html_forms','helpers'));

/** System Messages */
$_webnukes->load('messages_class', 'msg');

/** Admin functions */
if ( is_admin() )
{
	/** Theme activation configuration */
	if(isset($_GET['activated'] ) && $pagenow == "themes.php")
		require_once('config/installation.php');
	
	/** Plugin Activation */
	require_once(BASEPATH.DIRECTORY_SEPARATOR.'thirdparty'.DIRECTORY_SEPARATOR.'tgm-plugin-activation'.DIRECTORY_SEPARATOR.'plugins.php');

	/** We have to include stylesheets and javascript that's why we are not going to use built-in wordpress callback functions */
	if(isset($_GET['page']) && strstr($_GET['page'], 'fw_'))
	{
		if(isset($_GET['dummydata']))
		{
			$_webnukes->load('backup_class', 'backup');
			
			$_webnukes->backup->wp_option_import();
			$_webnukes->backup->sidebar_import();
			$_webnukes->backup->theme_options_import();
			$_webnukes->msg->create( __('The dummy data is installed successfully', THEME_NAME), 'success' );
			$_SERVER['REQUEST_URI'] = preg_replace('#\&dummydata=1#i', '', $_SERVER['REQUEST_URI']);
		}
		$_webnukes->load('options_class','options');
		
	}
	
	/** Register WPnukes Apanel pages links */
	function admin_menu_links()
	{
		/** Theme Options */
		add_theme_page( __('Theme Options', THEME_NAME), __('Theme Options', THEME_NAME), 'edit_user', 'fw_theme_options', 'fw_settings_page');
		//add_menu_page( __('WP Nukes', THEME_NAME), __('WP Nukes', THEME_NAME), 'manage_options', 'fw_theme_options', 'fw_settings_page');
	}

	add_action('admin_menu', 'admin_menu_links');
	
	/** fw_settings_page WPnukes Apanel pages processing and HTML builder */
	function fw_settings_page()
	{
		echo $GLOBALS['_webnukes']->html->build();
	}
	
	/** Load Plugins */
}

/** END ADMIN OPTIONS **/